﻿/*-------------------------------------
//
//Copyright (C) 2007 开发二组 版权所有。
//
//文件名：Cart.cs
//
//
//文件功能描述：显示商品类别....
//
//
//创建标识：2007.11.19 王志平
//创建描述：
//
//------------------------------------*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class UserControl_ProductClass : System.Web.UI.UserControl
{
    //调用WebServer方法..
    localhost.ProductService showProduct = new localhost.ProductService();
    protected void Page_Load(object sender, EventArgs e)
    {
        //当页面第一次调用时执行.
        if (!IsPostBack)
        {
            BindDataList();
        }
    }
    public string Title
    {
        get { return Location1.strLabelText;}
    }
    /// <summary>
    /// 进行数据绑定..
    /// </summary>
    protected void BindDataList()
    {
        
            DataSet dsUpperProduct = new DataSet();
            //
            //从数据库中读取大类别..
            //
            dsUpperProduct = showProduct.GetUpperCategoryList();
            //
            //将数据放到dlstProductClass表中.
            //
            dlstProductClass.DataSource = dsUpperProduct;
            dlstProductClass.DataBind();
       
    }
    /// <summary>
    /// 对绑定小类别
    /// </summary>
    /// <param name="sender">控件对象</param>
    /// <param name="e">控件参数</param>
    protected void dlstProductClass_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        
            DataSet dsLowProduct = new DataSet();
            //
            //从数据库中读取小类别..
            //
            dsLowProduct = showProduct.GetLowCategoryList();
            //
            //将表中的数据读到数据视图中...
            //
            DataView dv = dsLowProduct.Tables[0].DefaultView;
            dv.RowFilter = "UpperCategoryID='" + ((Label)e.Item.FindControl("lblUpperID")).Text + "'";
            //
            //将视图中满足条件的数据放到DataList2中..
            //
            ((DataList)e.Item.FindControl("DataList2")).DataSource = dv;
            //
            //绑定..
            //
            ((DataList)e.Item.FindControl("DataList2")).DataBind();
            //
            //绑定小类别ID
            //
            string upperID = ((Label)e.Item.FindControl("lblUpperID")).Text;
            //
            //将ID传入具体商品KindsProducts页面..
             //
            ((HyperLink)e.Item.FindControl("hypUpperName")).NavigateUrl = "../KindsProducts.aspx?upperID=" + upperID;
        
    }
    /// <summary>
    /// 对数据的绑定
    /// </summary>
    /// <param name="sender">控件对象</param>
    /// <param name="e">控件参数</param>
    protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)
    {
           //
           //绑定小类别ID
           //
           string lowID = ((Label)e.Item.FindControl("lblLowID")).Text;
           //
           //将ID传入具体商品MaterialProduct页面..
           //
          ((HyperLink)e.Item.FindControl("hypLowClass")).NavigateUrl = "../MaterialProduct.aspx?LowID=" + lowID;
        
    }
    
}
